$.extend({
  Common: {
    //region DefaultPrevented:处理屏蔽事件A标签
    DefaultPrevented: {
      A: $('<a style="display: none !important;"/>'),
      Content: $('<span/>'),
      Init: null,
      Call: function (e, element) {
        if (!e.isDefaultPrevented()) {
          return;
        }
        if (!this.Init) {
          this.A.append(this.Content);
        }
        if (!(element instanceof jQuery)) {
          element = $(element);
        }
        this.A.attr({
          'href': element.attr('href'),
          'target': element.attr('target')
        });
        this.Content.click();
      }
    },
    //endregion
    //region Bootstrap:BOOTSTRAP
    Bootstrap: {
      PageInit: function () {
        $('.selectpicker').selectpicker();
        $('#MenuTabs > li.disabled > [data-toggle="tab"]').click(function () {
          return false;
        });
        $.fn.ace_scroll.defaults = $.extend({}, $.fn.ace_scroll.defaults, {
          'lockAnyway': true,
          'observeContent': true
        });
        this.Tooltip();
      },
      Tooltip: function (element) {
        if (!element) {
          element = $('body');
        } else if (!(element instanceof jQuery)) {
          element = $(element);
        }
        if (element.attr('data-rel') == 'tooltip') {
          element.tooltip();
        }
        element.find('[data-rel="tooltip"]').tooltip();
      }
    },
    //endregion
    //region PageInit:初始化页面
    PageInit: function () {
      //绑定图片
      $.Common.ImageBind.fnBind();
      //绑定数据项
      $.Common.DataBind.fnBind();
    },
    //endregion
    //region PhoneVerifyCode:获取手机验证码倒计时
    PhoneVerifyCode: {
      Interval: 60,
      IntervalInit: 60,
      TimeoutObj: null,
      fnSend: function (Phone, onSuccess, onError) {
        if (!(/^1\d{10}$/).test(Phone)) {
          $.KOC.Tips.Open('Error', '请输入正确的手机号', {Timeout: 3000});
          return;
        }
        // $.Common.Geetest.fnInit(function (parm) {
        // parm.Phone = Phone;
        $.getJSON(_VirtualPath.Utils + 'ajax/base.phoneverifycode', {Phone: Phone}, function (json) {
          if (json.flag !== 0) {
            $.KOC.Tips.Open('Error', json.msg + '(' + json.flag + ')', {
              Timeout: 3000,
              onClose: function () {
                if (typeof onError === 'function') {
                  onError(json);
                }
              }
            });
            return;
          }
          $.Common.PhoneVerifyCode.Interval = $.Common.PhoneVerifyCode.IntervalInit;
          if (typeof onSuccess === 'function') {
            onSuccess(json);
          }
        });
        // });
      },
      fnCountdown: function (callback) {
        if ($.Common.PhoneVerifyCode.TimeoutObj) {
          clearInterval($.Common.PhoneVerifyCode.TimeoutObj);
          $.Common.PhoneVerifyCode.TimeoutObj = null;
        }
        $.Common.PhoneVerifyCode.Interval--;
        if (typeof callback === 'function') {
          callback($.Common.PhoneVerifyCode.Interval);
        }
        if ($.Common.PhoneVerifyCode.Interval <= 0) {
          $.Common.PhoneVerifyCode.Interval = $.Common.PhoneVerifyCode.IntervalInit;
          return;
        }
        $.Common.PhoneVerifyCode.TimeoutObj = setTimeout(function () {
          $.Common.PhoneVerifyCode.fnCountdown(callback);
        }, 1000);
      }
    },
    //endregion
    //region Geetest:极验验证
    Geetest: {
      CaptchaObj: null,
      fnInit: function (parm) {
        var _defaultConfig = {
          Mode: "popup",
          Container: "body",
          onSuccess: null,
          onReady: null
        };
        parm = $.extend(true, {}, _defaultConfig, (typeof parm === "function") ? {onSuccess: parm} : parm);
        $.getJSON(_VirtualPath.Utils + 'ajax/base.geetestregister',
          {},
          function (data) {
            if (data.flag !== 0) {
              $.KOC.Tips.Open('Error', data.msg, {
                Timeout: 1000
              });
              return;
            }
            data = data.data;
            initGeetest({
              gt: data.ID,
              challenge: data.Challenge,
              product: parm.Mode
            }, function (captchaObj) {
              $.Common.Geetest.CaptchaObj = captchaObj;
              captchaObj.appendTo(parm.Container);
              if (typeof parm.onSuccess === 'function') {
                captchaObj.onSuccess(function () {
                  parm.onSuccess(captchaObj.getValidate());
                });
              }
              captchaObj.onReady(function () {
                if (parm.Mode == "popup") {
                  captchaObj.show();
                }
                if (typeof parm.onReady === 'function') {
                  parm.onReady(captchaObj);
                }
              });
            });
          }
        );
      },
      fnRefresh: function () {
        if (!$.Common.Geetest.CaptchaObj) {
          return;
        }
        $.Common.Geetest.CaptchaObj.refresh();
      }
    },
    //endregion
    //region ImageBind:图片绑定
    ImageBind: {
      fnBind: function (element) {
        if (!element) {
          element = $('body');
        }
        if (!(element instanceof jQuery)) {
          element = $(element);
        }
        if (element.attr('ImageBind') && element.attr('ImageBind') == 'true') {
          return;
        }
        var _element;
        if (element.attr('ImageBind')) {
          _element = [element];
        }
        else {
          _element = element.find('[ImageBind][ImageBind!="true"]');
        }
        $(_element).each(function () {
          switch ($(this).attr('ImageBind')) {
            case 'UserAvatar'://用户头像
              $.Common.ImageBind.UserAvatar.fnBind(this);
              break;
            case 'UserCover'://用户封面
              $.Common.ImageBind.UserCover.fnBind(this);
              break;
          }
        });
      },
      //用户头像
      UserAvatar: {
        fnURL: function (User_ID, Size) {
          if (!User_ID || User_ID <= 0) {
            User_ID = _StateData.User_ID;
          }
          return _VirtualPath.Utils_CDN + 'service/img/user/avatar/' + User_ID + '/' + Size + '.jpg';
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('ImageBind') === 'true') {
            return;
          }
          element.attr('ImageBind', true);
          var _parms = {
            User_ID: $.KOC.String.ToInt(element.attr('ImageBind-ID'), -1),
            Size: element.attr('ImageBind-Size')
          };
          element.attr('src', this.fnURL(_parms.User_ID, _parms.Size));
        }
      },
      //用户封面
      UserCover: {
        fnURL: function (User_ID, Size) {
          if (!User_ID || User_ID <= 0) {
            User_ID = _StateData.User_ID;
          }
          return _VirtualPath.Utils_CDN + 'service/img/user/cover/' + User_ID + '/' + Size + '.jpg';
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('ImageBind') === 'true') {
            return;
          }
          element.attr('ImageBind', true);
          var _parms = {
            User_ID: $.KOC.String.ToInt(element.attr('ImageBind-ID'), -1),
            Size: element.attr('ImageBind-Size')
          };
          element.attr('src', this.fnURL(_parms.User_ID, _parms.Size));
        }
      },
      //实名身份证照
      UserIDCard: {
        fnURL: function (User_ID, Front) {
          if (!User_ID || User_ID <= 0) {
            User_ID = _StateData.User_ID;
          }
          return _VirtualPath.Utils + 'service/img/user/idcard-' + Front + '/' + User_ID + '.jpg';
        }
      }
    },
    //endregion
    //region DataBind:数据绑定
    DataBind: {
      //region fnBind
      fnBind: function (element) {
        if (!element) {
          element = $('body');
        }
        if (!(element instanceof jQuery)) {
          element = $(element);
        }
        if (element.attr('data-databind') && element.attr('data-databind') == 'true') {
          return;
        }
        var _element;
        if (element.attr('data-databind')) {
          _element = [element];
        }
        else {
          _element = element.find('[data-databind][data-databind!="true"]');
        }
        $(_element).each(function () {
          switch ($(this).attr('data-databind')) {
            case 'TradeCurrency'://交易币种
              $.Common.DataBind.TradeCurrency.fnBind(this);
              break;
            case 'UserBankTransaction'://用户帐户交易方式
              $.Common.DataBind.UserBankTransaction.fnBind(this);
              break;
            case 'UserPackageItemType'://用户包裹物品类型
              $.Common.DataBind.UserPackageItemType.fnBind(this);
              break;
            case 'UserPackageTransaction'://用户包裹交易方式
              $.Common.DataBind.UserPackageTransaction.fnBind(this);
              break;
            case 'FamilyBankTransaction'://公会帐户交易方式
              $.Common.DataBind.FamilyBankTransaction.fnBind(this);
              break;
            case 'CommodityGift'://商品.礼物
              $.Common.DataBind.CommodityGift.fnBind(this);
              break;
            case 'CommodityGuardian'://商品.守护
              $.Common.DataBind.CommodityGuardian.fnBind(this);
              break;
            case 'CommodityHorn'://商品.喇叭
              $.Common.DataBind.CommodityHorn.fnBind(this);
              break;
            case 'CommodityMounts'://商品.座骑
              $.Common.DataBind.CommodityMounts.fnBind(this);
              break;
            case 'CommodityVIP'://商品.VIP
              $.Common.DataBind.CommodityVIP.fnBind(this);
              break;
          }
        });
      },
      //endregion
      //region TradeCurrency
      TradeCurrency: {
        Data: [
          {id: 1, text: '金币 YB', Name: '金币'},
          {id: 2, text: '金豆 YD', Name: '金豆'}
        ],
        fnInfo: function (id) {
          return _.find(this.Data, {id: id});
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-default'), -1),
            DefaultText: element.attr('data-databind-default-text'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          element.select2({
            data: _.union([{
              id: -1,
              text: _parms.Placeholder
            }], this.Data),
            templateResult: function (repo) {
              return repo.Name || repo.text;
            },
            templateSelection: function (repo) {
              return repo.Name || repo.text;
            }
          });
          if (_parms.DefaultValue > 0) {
            element.select2('val', _parms.DefaultValue);
          }
        }
      },
      //endregion
      //region UserPackageItemType
      UserPackageItemType: {
        Data: [
          {id: "Gift", text: '礼物 LW', Name: '礼物'},
          {id: "Horn", text: '喇叭 LB', Name: '喇叭'}
        ],
        fnInfo: function (id) {
          return _.find(this.Data, {id: id});
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: element.attr('data-databind-default') || '',
            DefaultText: element.attr('data-databind-default-text'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          element.select2({
            data: _.union([{
              id: -1,
              text: _parms.Placeholder
            }], this.Data),
            templateResult: function (repo) {
              return repo.Name || repo.text;
            },
            templateSelection: function (repo) {
              return repo.Name || repo.text;
            }
          });
          if (_parms.DefaultValue) {
            element.select2('val', _parms.DefaultValue);
          }
        }
      },
      //endregion
      //region UserBankTransaction
      UserBankTransaction: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.userbanktransaction',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.UserBankTransaction.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.UserBankTransaction.Data = data.data;
                $.Common.DataBind.UserBankTransaction.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.UserBankTransaction.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name ? repo.GroupName + repo.GroupCurrency + repo.Name : repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name ? repo.GroupName + repo.GroupCurrency + repo.Name : repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region UserPackageTransaction
      UserPackageTransaction: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.userpackagetransaction',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.UserPackageTransaction.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.UserPackageTransaction.Data = data.data;
                $.Common.DataBind.UserPackageTransaction.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.UserPackageTransaction.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name ? repo.GroupName + repo.Name : repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name ? repo.GroupName + repo.Name : repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region FamilyBankTransaction
      FamilyBankTransaction: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.familybanktransaction',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.FamilyBankTransaction.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.FamilyBankTransaction.Data = data.data;
                $.Common.DataBind.FamilyBankTransaction.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.FamilyBankTransaction.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name ? repo.GroupName + repo.Name : repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name ? repo.GroupName + repo.Name : repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region CommodityGift
      CommodityGift: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.commoditygift',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.CommodityGift.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.CommodityGift.Data = data.data;
                $.Common.DataBind.CommodityGift.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.CommodityGift.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Status: element.attr('data-databind-status'),
            RoomTemplate: element.attr('data-databind-roomtemplate'),
            Tag: element.attr('data-databind-tag'),
            IsVIP: element.attr('data-databind-isvip') ? $.KOC.String.ToBoolean(element.attr('data-databind-isvip')) : null,
            IsGuardian: element.attr('data-databind-isguardian') ? $.KOC.String.ToBoolean(element.attr('data-databind-isguardian')) : null,
            IsLucky: element.attr('data-databind-islucky') ? $.KOC.String.ToBoolean(element.attr('data-databind-islucky')) : null,
            IsActivity: element.attr('data-databind-isactivity') ? $.KOC.String.ToBoolean(element.attr('data-databind-isactivity')) : null,
            IsWeekStar: element.attr('data-databind-isweekstar') ? $.KOC.String.ToBoolean(element.attr('data-databind-isweekstar')) : null,
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            if (_parms.Status) {
              var _Status = [];
              _.forEach(String(_parms.Status).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _Status.push(ThisValue);
                }
              });
              _parms.Status = _Status.length > 0 ? _Status : null;
            }
            if (_parms.RoomTemplate) {
              var _RoomTemplate = [];
              _.forEach(String(_parms.RoomTemplate).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _RoomTemplate.push(ThisValue);
                }
              });
              _parms.RoomTemplate = _RoomTemplate.length > 0 ? _RoomTemplate : null;
            }
            if (_parms.Tag) {
              var _Tag = [];
              _.forEach(String(_parms.Tag).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _Tag.push(ThisValue);
                }
              });
              _parms.Tag = _Tag.length > 0 ? _Tag : null;
            }
            if (_parms.Status
              || _parms.Tag
              || _parms.IsVIP != undefined
              || _parms.IsGuardian != undefined
              || _parms.IsLucky != undefined
              || _parms.IsActivity != undefined
              || _parms.IsWeekStar != undefined) {
              data = _.filter(data, function (ThisValue) {
                if (_parms.Status && !_.includes(_parms.Status, ThisValue.Status)) {
                  return false;
                }
                if (_parms.RoomTemplate && !_.intersection(_parms.RoomTemplate, ThisValue.RoomTemplate).length) {
                  return false;
                }
                if (_parms.Tag && !_.intersection(_parms.Tag, ThisValue.Tag).length) {
                  return false;
                }
                if (_parms.IsVIP != undefined && ThisValue.IsVIP != _parms.IsVIP) {
                  return false;
                }
                if (_parms.IsGuardian != undefined && ThisValue.IsGuardian != _parms.IsGuardian) {
                  return false;
                }
                if (_parms.IsLucky != undefined && ThisValue.IsLucky != _parms.IsLucky) {
                  return false;
                }
                if (_parms.IsActivity != undefined && ThisValue.IsActivity != _parms.IsActivity) {
                  return false;
                }
                if (_parms.IsWeekStar != undefined && ThisValue.IsWeekStar != _parms.IsWeekStar) {
                  return false;
                }
                return true;
              });
            }
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name || repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name || repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region CommodityGuardian
      CommodityGuardian: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.commodityguardian',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.CommodityGuardian.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.CommodityGuardian.Data = data.data;
                $.Common.DataBind.CommodityGuardian.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.CommodityGuardian.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Status: element.attr('data-databind-status'),
            Mode: element.attr('data-databind-mode'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            if (_parms.Status) {
              var _Status = [];
              _.forEach(String(_parms.Status).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _Status.push(ThisValue);
                }
              });
              _parms.Status = _Status.length > 0 ? _Status : null;
            }
            if (_parms.Mode) {
              _parms.Mode = _.compact(String(_parms.Mode).split(','));
              _parms.Mode = _parms.Mode.length > 0 ? _parms.Mode : null;
            }
            if (_parms.Status || _parms.Mode) {
              data = _.filter(data, function (ThisValue) {
                if (_parms.Status && !_.includes(_parms.Status, ThisValue.Status)) {
                  return false;
                }
                if (_parms.Mode && !_.includes(_parms.Mode, ThisValue.Mode)) {
                  return false;
                }
                return true;
              });
            }
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name || repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name || repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region CommodityHorn
      CommodityHorn: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.commodityhorn',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.CommodityHorn.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.CommodityHorn.Data = data.data;
                $.Common.DataBind.CommodityHorn.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.CommodityHorn.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Status: element.attr('data-databind-status'),
            Mode: element.attr('data-databind-mode'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            if (_parms.Status) {
              var _Status = [];
              _.forEach(String(_parms.Status).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _Status.push(ThisValue);
                }
              });
              _parms.Status = _Status.length > 0 ? _Status : null;
            }
            if (_parms.Mode) {
              _parms.Mode = _.compact(String(_parms.Mode).split(','));
              _parms.Mode = _parms.Mode.length > 0 ? _parms.Mode : null;
            }
            if (_parms.Status || _parms.Mode) {
              data = _.filter(data, function (ThisValue) {
                if (_parms.Status && !_.includes(_parms.Status, ThisValue.Status)) {
                  return false;
                }
                if (_parms.Mode && !_.includes(_parms.Mode, ThisValue.Mode)) {
                  return false;
                }
                return true;
              });
            }
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name || repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name || repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region CommodityMounts
      CommodityMounts: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.commoditymounts',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.CommodityMounts.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.CommodityMounts.Data = data.data;
                $.Common.DataBind.CommodityMounts.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.CommodityMounts.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Status: element.attr('data-databind-status'),
            Mode: element.attr('data-databind-mode'),
            Mall: element.attr('data-databind-mall') ? $.KOC.String.ToBoolean(element.attr('data-databind-mall')) : null,
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            if (_parms.Status) {
              var _Status = [];
              _.forEach(String(_parms.Status).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _Status.push(ThisValue);
                }
              });
              _parms.Status = _Status.length > 0 ? _Status : null;
            }
            if (_parms.Mode) {
              _parms.Mode = _.compact(String(_parms.Mode).split(','));
              _parms.Mode = _parms.Mode.length > 0 ? _parms.Mode : null;
            }
            if (_parms.Status || _parms.Mode || _parms.Mall != undefined) {
              data = _.filter(data, function (ThisValue) {
                if (_parms.Status && !_.includes(_parms.Status, ThisValue.Status)) {
                  return false;
                }
                if (_parms.Mode && !_.includes(_parms.Mode, ThisValue.Mode)) {
                  return false;
                }
                if (_parms.Mall != undefined && ThisValue.Mall != _parms.Mall) {
                  return false;
                }
                return true;
              });
            }
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name || repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name || repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      },
      //endregion
      //region CommodityVIP
      CommodityVIP: {
        Data: null,
        fnData: function (onComplete) {
          if (this.Data) {
            if (typeof onComplete === 'function') {
              onComplete(this.Data);
            }
            return;
          }
          if (this.Data !== 0) {
            this.Data = 0;
            $.ajax({
              url: _VirtualPath.Utils + 'ajax/databind.commodityvip',
              type: 'post',
              dataType: 'json',
              success: function (data) {
                if (data.flag !== 0) {
                  $.Common.DataBind.CommodityVIP.Data = null;
                  if (typeof onComplete === 'function') {
                    onComplete();
                  }
                  return;
                }
                $.Common.DataBind.CommodityVIP.Data = data.data;
                $.Common.DataBind.CommodityVIP.fnData(onComplete);
              }
            });
            return;
          }
          setTimeout(function () {
            $.Common.DataBind.CommodityVIP.fnData(onComplete);
          }, 200);
        },
        fnInfo: function (id, onComplete) {
          if (!id) {
            if (typeof onComplete === 'function') {
              onComplete();
            }
            return;
          }
          if (typeof onComplete !== 'function') {
            if (this.Data) {
              return _.find(this.Data, {id: id});
            }
            return;
          }
          this.fnData(function (data) {
            onComplete(_.find(data, {id: $.KOC.String.ToInt(id)}));
          });
        },
        fnBind: function (element) {
          if (!element) {
            return;
          }
          if (!(element instanceof jQuery)) {
            element = $(element);
          }
          if (element.attr('data-databind') === 'true') {
            return;
          }
          element.attr('data-databind', true).empty();
          var _parms = {
            DefaultValue: $.KOC.String.ToInt(element.attr('data-databind-Default'), -1),
            DefaultText: element.attr('data-databind-DefaultText'),
            Status: element.attr('data-databind-status'),
            Mode: element.attr('data-databind-mode'),
            Placeholder: element.attr('placeholder') || '请选择…'
          };
          if (element.prop('disabled') && _parms.DefaultValue > 0 && _parms.DefaultText) {
            element.append($("<option/>", {
              value: _parms.DefaultValue,
              text: _parms.DefaultText
            })).select2();
            return;
          }
          this.fnData(function (data) {
            if (_parms.Status) {
              var _Status = [];
              _.forEach(String(_parms.Status).split(','), function (ThisValue) {
                if ($.KOC.String.ToInt(ThisValue, -1) >= 0) {
                  _Status.push(ThisValue);
                }
              });
              _parms.Status = _Status.length > 0 ? _Status : null;
            }
            if (_parms.Mode) {
              _parms.Mode = _.compact(String(_parms.Mode).split(','));
              _parms.Mode = _parms.Mode.length > 0 ? _parms.Mode : null;
            }
            if (_parms.Status || _parms.Mode) {
              data = _.filter(data, function (ThisValue) {
                if (_parms.Status && !_.includes(_parms.Status, ThisValue.Status)) {
                  return false;
                }
                if (_parms.Mode && !_.includes(_parms.Mode, ThisValue.Mode)) {
                  return false;
                }
                return true;
              });
            }
            data = _.union([{
              id: -1,
              text: _parms.Placeholder
            }], data);
            element.select2({
              data: data,
              templateResult: function (repo) {
                return repo.Name || repo.text;
              },
              templateSelection: function (repo) {
                return repo.Name || repo.text;
              }
            });
            if (_parms.DefaultValue > 0) {
              element.select2('val', _parms.DefaultValue);
            }
          });
        }
      }
      //endregion
    },
    //endregion
    //region Permission:权限管理
    Permission: {
      Check: function (code, type) {
        //return false;
        try {
          _StateData;
        } catch (ex) {
          return false;
        }
        if (!_StateData.IsLogin) {
          return false;
        }
        var _UserRight = {
          Code: '',
          CodeDefalut: '',
          IsMaster: false,
          IsMasterDefault: false
        };
        switch (type) {
          case "Admin":
            if (!_StateData.IsAdmin) {
              return false;
            }
            _UserRight.CodeDefalut = _StateData.Admin.RightCode;
            _UserRight.IsMasterDefault = _StateData.Admin.IsMaster;
            break;
          case "Family":
            if (!_StateData.IsFamily) {
              return false;
            }
            _UserRight.CodeDefalut = _StateData.Family.RightCode;
            _UserRight.IsMasterDefault = _StateData.Family.IsMaster;
            break;
          case "Anchor":
            if (!_StateData.IsAnchor) {
              return false;
            }
            break;
          case "User":
          default:
            break;
        }
        if (!code) {
          return true;
        }
        var _code = _.compact(String(code).split('|'));
        for (var i in _code) {
          code = $.trim(_code[i]).split(':');
          if (code.length > 2) {
            continue;
          }
          if (code.length == 2) {
            switch (code[0]) {
              case "Admin":
                _UserRight.Code = _StateData.Admin.RightCode;
                _UserRight.IsMaster = _StateData.Admin.IsMaster;
                break;
              case "Family":
                _UserRight.Code = _StateData.Family.RightCode;
                _UserRight.IsMaster = _StateData.Family.IsMaster;
                break;
              case "Anchor":
              case "User":
              default:
                _UserRight.Code = '';
                _UserRight.IsMaster = false;
                break;
            }
            code = code[1];
          } else {
            _UserRight.Code = _UserRight.CodeDefalut;
            _UserRight.IsMaster = _UserRight.IsMasterDefault;
            code = code[0];
          }
          if (_UserRight.IsMaster || _UserRight.Code.indexOf(code) >= 0) {
            return true;
          }
        }
        return false;
      },
      CheckElement: function (element, type) {
        if (!element) {
          element = $('body');
        }
        if (!(element instanceof jQuery)) {
          element = $(element);
        }
        if (element.data('permission-code') && !$.Common.Permission.Check($(this).data('permission-code'), type)) {
          if ($(this).data('permission-disabled')) {
            $(this).addClass('disabled').prop('disabled', true);
          } else {
            $(this).remove();
            return;
          }
        }
        $(element.find('[data-permission-code]')).each(function () {
          if (!$.Common.Permission.Check($(this).data('permission-code'), type)) {
            if ($(this).data('permission-disabled')) {
              $(this).addClass('disabled').prop('disabled', true);
            } else {
              $(this).remove();
            }
          }
        });
      }
    },
    //endregion

    //获得省份
    GetProvince: function () {
      var Province = [
        '北京', '上海', '天津', '重庆', '浙江', '黑龙江', '辽宁', '四川', '安徽', '福建', '甘肃', '广东', '广西', '贵州', '海南', '河北', '河南', '山东', '湖北', '湖南', '吉林', '江苏', '江西', '内蒙古', '青海', '山西', '陕西', '西藏', '新疆', '云南', '香港', '澳门', '台湾'
      ];
      return Province;
    },
    //获得指定省份下的市
    GetRegion: function (name) {
      var parm = {
        '北京': ['北京'],
        '上海': ['上海'],
        '天津': ['天津'],
        '重庆': ['重庆'],
        '香港': ['香港'],
        '澳门': ['澳门'],
        '台湾': ['台湾'],
        '安徽': [
          '安庆', '蚌埠', '巢湖', '池州', '滁州', '阜阳', '淮北', '淮南', '黄山', '六安', '马鞍山', '宿州', '铜陵', '芜湖', '宣城', '亳州', '合肥'
        ],
        '福建': [
          '福州', '龙岩', '南平', '宁德', '莆田', '泉州', '三明', '厦门', '漳州'
        ],
        '甘肃': [
          '兰州', '白银', '定西', '甘南', '嘉峪关', '金昌', '酒泉', '临夏', '陇南', '平凉', '庆阳', '天水', '武威', '张掖'
        ],
        '广东': [
          '广州', '深圳', '潮州', '东莞', '佛山', '河源', '惠州', '江门', '揭阳', '茂名', '梅州', '清远', '汕头', '汕尾', '韶关', '阳江', '云浮', '湛江', '肇庆', '中山', '珠海'
        ],
        '广西': [
          '南宁', '桂林', '百色', '北海', '崇左', '防城港', '贵港', '河池', '贺州', '来宾', '柳州', '钦州', '梧州', '玉林'
        ],
        '贵州': [
          '贵阳', '安顺', '毕节', '六盘水', '黔东南', '黔南', '黔西南', '铜仁', '遵义'
        ],
        '海南': [
          '海口', '三亚', '白沙', '保亭', '昌江', '澄迈县', '定安县', '东方', '乐东', '临高县', '陵水', '琼海', '琼中', '屯昌县', '万宁', '文昌', '五指山', '儋州'
        ],
        '河北': [
          '石家庄', '保定', '沧州', '承德', '邯郸', '衡水', '廊坊', '秦皇岛', '唐山', '邢台', '张家口'
        ],
        '河南': [
          '郑州', '洛阳', '开封', '安阳', '鹤壁', '济源', '焦作', '南阳', '平顶山', '三门峡', '商丘', '新乡', '信阳', '许昌', '周口', '驻马店', '漯河', '濮阳'
        ],
        '黑龙江': [
          '哈尔滨', '大庆', '大兴安岭', '鹤岗', '黑河', '鸡西', '佳木斯', '牡丹江', '七台河', '齐齐哈尔', '双鸭山', '绥化', '伊春'
        ],
        '湖北': [
          '武汉', '仙桃', '鄂州', '黄冈', '黄石', '荆门', '荆州', '潜江', '神农架林区', '十堰', '随州', '天门', '咸宁', '襄阳', '孝感', '宜昌', '恩施'
        ],
        '湖南': [
          '长沙', '张家界', '常德', '郴州', '衡阳', '怀化', '娄底', '邵阳', '湘潭', '湘西', '益阳', '永州', '岳阳', '株洲'
        ],
        '吉林': [
          '长春', '吉林', '白城', '白山', '辽源', '四平', '松原', '通化', '延边'
        ],
        '江苏': [
          '南京', '苏州', '无锡', '常州', '淮安', '连云港', '南通', '宿迁', '泰州', '徐州', '盐城', '扬州', '镇江'
        ],
        '江西': [
          '南昌', '抚州', '赣州', '吉安', '景德镇', '九江', '萍乡', '上饶', '新余', '宜春', '鹰潭'
        ],
        '辽宁': [
          '沈阳', '大连', '鞍山', '本溪', '朝阳', '丹东', '抚顺', '阜新', '葫芦岛', '锦州', '辽阳', '盘锦', '铁岭', '营口'
        ],
        '内蒙古': [
          '呼和浩特', '阿拉善盟', '巴彦淖尔盟', '包头', '赤峰', '鄂尔多斯', '呼伦贝尔', '通辽', '乌海', '乌兰察布市', '锡林郭勒盟', '兴安盟'
        ],
        '宁夏': [
          '银川', '固原', '石嘴山', '吴忠', '中卫'
        ],
        '青海': [
          '西宁', '果洛', '海北', '海东', '海南', '海西', '黄南', '玉树'
        ],
        '山东': [
          '济南', '青岛', '滨州', '德州', '东营', '菏泽', '济宁', '莱芜', '聊城', '临沂', '日照', '泰安', '威海', '潍坊', '烟台', '枣庄', '淄博'
        ],
        '山西': [
          '太原', '长治', '大同', '晋城', '晋中', '临汾', '吕梁', '朔州', '忻州', '阳泉', '运城'
        ],
        '陕西': [
          '西安', '安康', '宝鸡', '汉中', '商洛', '铜川', '渭南', '咸阳', '延安', '榆林'
        ],
        '四川': [
          '成都', '绵阳', '阿坝', '巴中', '达州', '德阳', '甘孜', '广安', '广元', '乐山', '凉山', '眉山', '南充', '内江', '攀枝花', '遂宁', '雅安', '宜宾', '资阳', '自贡', '泸州'
        ],
        '西藏': [
          '拉萨', '阿里', '昌都', '林芝', '那曲', '日喀则', '山南'
        ],
        '新疆': [
          '乌鲁木齐', '阿克苏', '阿拉尔', '巴音郭楞', '博尔塔拉', '昌吉', '哈密', '和田', '喀什', '克拉玛依', '克孜勒苏', '石河子', '图木舒克', '吐鲁番', '五家渠', '伊犁'
        ],
        '云南': [
          '昆明', '怒江', '普洱', '丽江', '保山', '楚雄', '大理', '德宏', '迪庆', '红河', '临沧', '曲靖', '文山', '西双版纳', '玉溪', '昭通'
        ],
        '浙江': [
          '杭州', '湖州', '嘉兴', '金华', '丽水', '宁波', '绍兴', '台州', '温州', '舟山', '衢州'
        ]
      };
      return parm[name];
    },
    //////////////////////////////////////////////
    //模态窗体
    //////////////////////////////////////////////
    ModalWindow: {
      widthMin: 1100,
      widthMax: 1180,
      heightMin: 500,
      heightMax: 765,
      onEnter: null,
      configDef: {
        scrolling: false,
        iframe: true,
        fixed: true,
        closeButton: false,
        overlayClose: false,
        innerWidth: 0,
        innerHeight: 0,
        href: null,
        onClosed: null
      },
      fnEnter: function (close, parms) {
        if (typeof close !== 'boolean') {
          parms = close;
          try {
            close = _ModalData.EnterClose;
          } catch (ex) {
            close = false;
          }
        }
        if (typeof parent.$.Common.ModalWindow.onEnter == 'function') {
          parent.$.Common.ModalWindow.onEnter(parms);
        }
        if (close) {
          parent.$.colorbox.close();
        }
        return close;
      },
      Open: function (parms, onEnter, onClose) {
        this.configDef.innerHeight = $(window).height() - 40;
        if (this.configDef.innerHeight > this.heightMax) {
          this.configDef.innerHeight = this.heightMax;
        }
        if (this.configDef.innerHeight < this.heightMin) {
          this.configDef.innerHeight = this.heightMin;
        }
        this.configDef.innerWidth = $(window).width() - 20;
        if (this.configDef.innerWidth > this.widthMax) {
          this.configDef.innerWidth = this.widthMax;
        }
        if (this.configDef.innerWidth < this.widthMin) {
          this.configDef.innerWidth = this.widthMin;
        }
        var _parms = null;
        if (typeof parms === 'string') {
          this.configDef.href = parms;
        } else {
          _parms = parms;
        }
        this.onEnter = onEnter;
        if (typeof onClose === 'function') {
          this.configDef.onClosed = onClose;
        }
        $.colorbox($.extend(true, {}, this.configDef, _parms));
      }
    }
  }
});